package com.cyc.basic.controller;

import com.cyc.basic.util.OssUtil;
import com.cyc.common.model.ApiResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author chenyunchang
 * @title
 * @date 2021/3/19 10:13
 * @Description:
 */
@RestController
@Api(tags = "阿里云相关接口")
@RequestMapping("/aliyun")
public class AliyunController {

    @Autowired
    private OssUtil ossUtil;

    @ApiOperation(value = "上传文件", produces = MediaType.MULTIPART_FORM_DATA_VALUE)
    @PostMapping(value = "/postFile", headers = "content-type=multipart/form-data")
    public ApiResult<String> postFile(@ApiParam(value = "file", required = true) MultipartFile file) {
        String url = ossUtil.checkImage(file);
        return ApiResult.success(url);
    }
}
